package lee.vioson.ebook.ui

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.ButtonColors
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.ColorScheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.sp

/**
 *Author:viosonlee
 *Date:2023/6/1
 *DESCRIPTION:
 */

val LocalMyColors = staticCompositionLocalOf {
    lightColorConfig
}


object AppTheme {

    val colors: ColorScheme
        @Composable
        get() = LocalMyColors.current.colorScheme

    val appColors: AppColor
        @Composable
        get() = LocalMyColors.current.appColor


    val titleStyle: TextStyle
        @Composable
        get() = TextStyle(
            fontSize = 18.sp,
            color = colors.onBackground
        )

    @Composable
    fun vipButtonColors(): ButtonColors = ButtonDefaults.buttonColors(
        containerColor = colors.secondary,
        contentColor = colors.onSecondary,
        disabledContainerColor = appColors.grayIconColor,
        disabledContentColor = appColors.grayIconColor
    )

    @Composable
    fun loginButtonColors(): ButtonColors = ButtonDefaults.buttonColors(
        containerColor = colors.onBackground,
        contentColor = colors.background,
        disabledContainerColor = appColors.loginButtonDisableContainerColor,
        disabledContentColor = appColors.loginButtonDisableContentColor
    )

}


@Composable
fun AppTheme(
    darkTheme: Boolean = isSystemInDarkTheme(),
    content: @Composable () -> Unit
) {
    val appColor = if (darkTheme) darkColorConfig else lightColorConfig
    CompositionLocalProvider(
        LocalMyColors provides appColor
    ) {
        MaterialTheme(
            colorScheme = appColor.colorScheme,
            content = content
        )
    }
}

